﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bovril.PlayingCards.French
{
    public class RankValue
    {
        public const int MaxValue = 14;
        public const int Ace = 14;
        public const int King = 13;
        public const int Queen = 12;
        public const int Jack = 11;
        public const int Ten = 10;
        public const int Nine = 9;
        public const int Eight = 8;
        public const int Seven = 7;
        public const int Six = 6;
        public const int Five = 5;
        public const int Four = 4;
        public const int Three = 3;
        public const int Two = 2;
        public const int MinValue = 2;

        private static String[] asText_ = new String[15]
        {
            String.Empty,
            String.Empty,
            "Two",
            "Three",
            "Four",
            "Five",
            "Six",
            "Seven",
            "Eight",
            "Nine",
            "Ten",
            "Jack",
            "Queen",
            "King",
            "Ace",
        };

        public static String ToString(int rankValue)
        {
            return asText_[rankValue];
        }

        public static int FromString(String str)
        {
            for (int rank = MaxValue; rank >= MinValue; --rank)
            {
                if (asText_[rank] == str)
                    return rank;
            }

            throw new ArgumentException("Unable to lookup rank", "text");
        }

        public static String[] GetAllValuesAsStrings()
        {
            return new String[]
            {
                asText_[RankValue.Ace],
                asText_[RankValue.King],
                asText_[RankValue.Queen],
                asText_[RankValue.Jack],
                asText_[RankValue.Ten],
                asText_[RankValue.Nine],
                asText_[RankValue.Eight],
                asText_[RankValue.Seven],
                asText_[RankValue.Six],
                asText_[RankValue.Five],
                asText_[RankValue.Four],
                asText_[RankValue.Three],
                asText_[RankValue.Two]
            };
        }
    }
}
